home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / EmbedHtmlMenuCellRenderer.as < prev    next >
Text File  |  2007-11-08  |  4KB  |  138 lines

  1. class EmbedHtmlMenuCellRenderer extends mx.core.UIComponent
  2. {
  3.    static var style_sheet = null;
  4.    var previousLabel = null;
  5.    function EmbedHtmlMenuCellRenderer()
  6.    {
  7.       super();
  8.       this.cssStyle = "menuRowTextEmbed";
  9.    }
  10.    function createChildren(Void)
  11.    {
  12.       if(this.htmlComponent == undefined)
  13.       {
  14.          this.createLabel("htmlComponent",1);
  15.       }
  16.       this.htmlComponent.html = true;
  17.       this.htmlComponent.border = false;
  18.       this.htmlComponent.multiline = false;
  19.       this.htmlComponent.wordWrap = false;
  20.       this.htmlComponent.selectable = false;
  21.       this.htmlComponent.styleSheet = EmbedHtmlMenuCellRenderer.style_sheet;
  22.       this.htmlComponent.embedFonts = true;
  23.       this.htmlComponent.antiAliasType = "advanced";
  24.       this.htmlComponent.sharpness = -300;
  25.       this.htmlComponent.thickness = -50;
  26.       this._parent.drawRowFill = this.drawRowFill;
  27.       this.size();
  28.    }
  29.    function size(Void)
  30.    {
  31.       this.htmlComponent.setSize(this.__width,this.__height - 2);
  32.       var _loc2_ = 2;
  33.       if(EmbedHtmlMenuCellRenderer.style_sheet)
  34.       {
  35.          var _loc3_ = EmbedHtmlMenuCellRenderer.style_sheet.getStyle("." + this.cssStyle);
  36.          if(_loc3_)
  37.          {
  38.             _loc2_ = Math.max(0,Math.floor((this.__height - _loc3_.fontSize - 1 - 2) / 2));
  39.          }
  40.       }
  41.       this.htmlComponent._y = _loc2_;
  42.    }
  43.    function setValue(str, item, sel)
  44.    {
  45.       if(item == undefined)
  46.       {
  47.          this.htmlComponent.htmlText = str;
  48.          this.previousLabel = null;
  49.          return undefined;
  50.       }
  51.       var _loc6_ = this.columnIndex;
  52.       var _loc7_ = this.getDataLabel();
  53.       var _loc3_ = str;
  54.       var _loc4_ = this.HtmlFunction(item.label);
  55.       _loc3_ = "<span class=\'" + this.cssStyle + "\'>" + _loc4_ + "</span>";
  56.       this.htmlComponent.htmlText = _loc3_;
  57.       if(item.cellEnabled == false && !this.disableRect)
  58.       {
  59.          this.disableRect = this.createRectangle(-2,0,this.__width + 2,this.__height + 1,16777215,"disableRect");
  60.          this.disableRect.onPress = function()
  61.          {
  62.          };
  63.          this.disableRect.useHandCursor = false;
  64.          this.disableRect._alpha = 30;
  65.          this.setColor(this.owner.getStyle("disabledColor"));
  66.       }
  67.       if(item.cellEnabled == true && this.disableRect)
  68.       {
  69.          this.disableRect._visible = false;
  70.       }
  71.    }
  72.    function createRectangle(inX, inY, w, h, bgColor, name)
  73.    {
  74.       var _loc2_ = this.createEmptyMovieClip(name,this.getNextHighestDepth());
  75.       _loc2_.beginFill(bgColor);
  76.       _loc2_.lineTo(w,0);
  77.       _loc2_.lineTo(w,h);
  78.       _loc2_.lineTo(0,h);
  79.       _loc2_.lineTo(0,0);
  80.       _loc2_._x = inX;
  81.       _loc2_._y = inY;
  82.       return _loc2_;
  83.    }
  84.    function getPreferredHeight(Void)
  85.    {
  86.       if(this.owner == undefined)
  87.       {
  88.          return 18;
  89.       }
  90.       return this.owner.__height;
  91.    }
  92.    function HtmlFunction(inLabel)
  93.    {
  94.       if(inLabel.indexOf("<sup>") >= 0 || inLabel.indexOf("<sub>") >= 0)
  95.       {
  96.          return StringUtils.subSupFromHTML(inLabel);
  97.       }
  98.       return inLabel;
  99.    }
  100.    function setColor(col)
  101.    {
  102.       if(this.htmlComponent != undefined)
  103.       {
  104.          this.htmlComponent.textColor = col;
  105.       }
  106.    }
  107.    function drawRowFill(mc, newClr)
  108.    {
  109.       mc.clear();
  110.       mc.beginFill(16777215);
  111.       mc.drawRect(0,0,this.__width,this.__height);
  112.       mc.beginFill(newClr);
  113.       mc.drawRect(0,1,this.__width,this.__height);
  114.       mc.endFill();
  115.       mc._width = this.__width;
  116.       mc._height = this.__height;
  117.       mc._alpha = 90;
  118.    }
  119.    static function displayStyleSheet(my_styleSheet)
  120.    {
  121.       var _loc5_ = my_styleSheet.getStyleNames();
  122.       if(_loc5_.length)
  123.       {
  124.          var _loc3_ = 0;
  125.          while(_loc3_ < _loc5_.length)
  126.          {
  127.             var _loc4_ = _loc5_[_loc3_];
  128.             var _loc1_ = my_styleSheet.getStyle(_loc4_);
  129.             for(var _loc6_ in _loc1_)
  130.             {
  131.                var _loc2_ = _loc1_[_loc6_];
  132.             }
  133.             _loc3_ = _loc3_ + 1;
  134.          }
  135.       }
  136.    }
  137. }
  138.